<?php if(!empty($_GET['act']) && ($_GET['act'] == 'bought')):?>
    <div class="row">
        <h2><b>已买到的宝贝</b></h2>
    </div>
    <table class="table row col-md-12 mt20">
        <tr>
            <th class="col-md-2 text-center">宝贝图片</th>
            <th class="col-md-2 text-center">宝贝名称</th>
            <th class="col-md-2 text-center">单价</th>
            <th class="col-md-2 text-center">数量</th>
            <th class="col-md-2 text-center">实付款</th>
            <th class="col-md-2 text-center">状态</th>
        </tr>
        <?php foreach($order_list as $value):?>
            <tr>
                <td colspan="6">
                    订单号:<?php echo $value['ordernum']?>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    订单创建时间:<?php echo $value['create_time']?>
                </td>
            </tr>
            <?php
            //查询订单管理的商品
            $sql = "select * from ".PRE."ordergoods where order_id='".$value['id']."'";
            $order_goods_info = query($link, $sql);
            ?>
            <?php foreach ($order_goods_info as $item):?>
                <?php
                //查询订单管理的商品
                $sql = "select g.id,g.gname,i.iname from ".PRE."goods as g,".PRE."image as i where g.id=i.goods_id and g.id =
'".$item['goods_id']."'and i.cover=1 limit 1";
                $goods_info = getRow($link, $sql);
                ?>
                <tr>
                    <td class="text-center">
                        <a href="<?php echo ROOT_URL?>goods_details.php?id=<?php echo  $goods_info['id']?>"><img src="<?php echo get_img_url(ROOT_URL.'upload/',$goods_info['iname'],50)?>"></a>
                    </td>
                    <td class="text-center"><a href="<?php echo ROOT_URL?>goods_details.php?id=<?php echo $goods_info['id']?>"><?php echo $goods_info['gname']?></a></td>
                    <td class="text-center"><?php echo $item['price']?></td>
                    <td class="text-center"><?php echo $item['qty']?></td>
                    <td class="text-center"><?php echo sprintf("%.2f", $item['qty']*$item['price'])?></td>
                    <td class="text-center">
                        <?php
                        switch($value['order_status']){
                            case 0: echo "未发货"; break;
                            case 1: echo "已发货"; break;
                            case 2: echo "已完成"; break;
                            case 3: echo "已失效"; break;
                        }
                        ?>

                        <?php if($value['order_status'] == 2):?>
                            <br>
                            <?php //查看是否已经对该商品进行评价
                                $sql = "select id from ".PRE."evaluate where user_id='".$_SESSION['home']['id']."' and  goods_id='".$goods_info['id']."' limit 1 ";
                                $res = getRow($link, $sql);
                            ?>
                            <?php if($res):?>
                                已评价
                                <br>
                                <a href="<?php echo ROOT_URL?>goods_evaluate.php?goods_id=<?php echo $goods_info['id']?>">追加评价</a>
                            <?php else:?>
                                <a href="<?php echo ROOT_URL?>goods_evaluate.php?goods_id=<?php echo $goods_info['id']?>">评价</a>

                            <?php endif;?>

                        <?php endif;?>
                    </td>
                </tr>
            <?php endforeach;?>
            <tr>
                <td colspan="4">&nbsp;</td>
                <td>&nbsp;</td>
                <td>
                    <?php if($value['order_status'] == 1):?>
                        <a href="<?php echo ROOT_URL?>com/buydo.php?act=confirm&order_id=<?php echo $value['id']?>" class="btn btn-danger">确认收货</a>
                    <?php elseif($value['order_status'] == 2):?>
                        <a href="" class="btn btn-success">已收货</a>
                    <?php endif;?>
                </td>
            </tr>
        <?php endforeach;?>
    </table>
<?php endif;?>